import 'package:yqmssa_app/request/http_path.dart';
import 'package:yqmssa_app/request/my_request.dart';
import 'package:yqmssa_app/views/index/request/index_request.dart';

class ApplyRequest {
  ApplyRequest._();

  static Future<CreateApplyDataModel> plan(Map<String, dynamic> putData) async {
    final data = {"province": '重庆', "city": "重庆", 'service_id': "", 'age_range': "28", ...putData};
    final res = await MyRequest().dioReq(HttpPath.signUp, data: data);
    return CreateApplyDataModel.fromJson(res["data"]);
  }

  static Future<VideoDetailDataModel> getVI(int id) async {
    final data = {"video_id": "$id"};
    final res = await MyRequest().dioReq(HttpPath.dt, data: data);
    return VideoDetailDataModel.fromJson(res["data"]);
  }

  static Future getQuestion() async {
    final res = await MyRequest().dioReq(HttpPath.questions);
    return res["data"];
  }
}

class IndexDataModel {
  IndexDataModel({
    required this.moneyRange,
    required this.video,
    this.submitImage = "",
    this.adminId = 0,
    this.fullName = "",
    this.statementTitle = "",
    this.statementContent = "",
  });

  late final List<MoneyRange> moneyRange;
  late final Video video;
  late String submitImage;
  late final int adminId;
  late final String fullName;
  late final String statementTitle;
  late final String statementContent;

  IndexDataModel.fromJson(Map<String, dynamic> json) {
    moneyRange = List.from(json['money_range']).map((e) => MoneyRange.fromJson(e)).toList();
    video = Video.fromJson(json['video']);
    submitImage = json['submit_image'];
    adminId = json['admin_id'];
    fullName = json['full_name'];
    statementTitle = json['statement_title'];
    statementContent = json['statement_content'];
  }
}

class MoneyRange {
  late final int id;
  late final String money;

  MoneyRange.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    money = json['money'];
  }
}

class Video {
  Video({
    this.workType = 0,
    this.limitPlace = "",
    this.limitAgeRange = "",
    this.status = "",
    this.id = 0,
    this.title = "",
    this.videofile = "",
    this.fengImage = "",
    this.twiceImg = "",
    this.boNumber = 0,
    this.introduceImage = "",
    this.isJumpMiniprogram = 0,
    this.isJumpWeb = 0,
    this.minAge = 0,
    this.advOrigin = "",
  });

  late final int workType;
  late final String limitPlace;
  late final String limitAgeRange;
  late final String status;
  late final int id;
  late final String title;
  late final String videofile;
  late final String fengImage;
  late final String twiceImg;
  late final int boNumber;
  late final String introduceImage;
  late final int isJumpMiniprogram;
  late final int isJumpWeb;
  late final int minAge;
  late final String advOrigin;

  Video.fromJson(Map<String, dynamic> json) {
    workType = json['work_type'];
    limitPlace = json['limit_place'];
    limitAgeRange = json['limit_age_range'];
    status = json['status'];
    id = json['id'];
    title = json['title'];
    videofile = json['videofile'];
    fengImage = json['feng_image'];
    twiceImg = json['twice_img'];
    boNumber = json['bo_number'];
    introduceImage = json['introduce_image'];
    isJumpMiniprogram = json['is_jump_miniprogram'];
    isJumpWeb = json['is_jump_web'];
    minAge = json['min_age'];
    advOrigin = json['adv_origin'];
  }
}

class CreateApplyDataModel {
  CreateApplyDataModel({
    this.serviceTencentId = "",
    this.id = 0,
    this.serviceName = "",
    this.mobile = "",
    this.qrcodeImage = "",
    this.legalTeacher = "",
    this.customerAcquisition = "",
  });

  late String serviceTencentId;
  late int id;
  late String serviceName;
  late String mobile;
  late String qrcodeImage;
  late String legalTeacher;
  late String customerAcquisition;

  CreateApplyDataModel.fromJson(Map<String, dynamic> json) {
    serviceTencentId = json['service_tencent_id'];
    id = json['id'];
    serviceName = json['service_name'];
    mobile = json['mobile'];
    qrcodeImage = json['qrcode_image'];
    legalTeacher = json['legal_teacher'];
    customerAcquisition = json['customer_acquisition'] ?? "";
  }

  Map<String, dynamic> toJson() {
    final _data = <String, dynamic>{};
    _data['service_tencent_id'] = serviceTencentId;
    _data['id'] = id;
    _data['service_name'] = serviceName;
    _data['mobile'] = mobile;
    _data['qrcode_image'] = qrcodeImage;
    _data['legal_teacher'] = legalTeacher;
    _data['customer_acquisition'] = customerAcquisition;
    return _data;
  }
}
